package wlt.xxljob.config;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;
import wlt.xxljob.service.LoginService;

/**
 * 启动时测试登录xxl-job-admin
 * @author wuliting
 * @date 2021/12/9
**/
@Slf4j
@Component
public class ContextStartedNotifier {
    @Autowired
    private LoginService loginService;

    @EventListener({ContextRefreshedEvent.class})
    public void processEvent() {
        log.info(">>>>>>>>>>> try to login xxl-job-admin >>>>>>>>>>>>>");
        try {
            loginService.login("admin","123456");
        }catch (Exception e) {
            log.info(">>>>>>>>>>> login failed >>>>>>>>>>>>>");
            log.error(e.toString(),e);
        }
    }
}
